# _*_ coding: utf-8 _*_
 
# @File    :   抽象工厂.py
# @Version :   xxx
# @Author  :   grit
# @Email   :   2285839445@qq.com
# @Time    :   2020/08/22 22:44:56
#Description:

import abc
import os
BASE_DIR = os.path()


# ! 产品:Pizza基类
class Pizza:
    # ! 真正的 产品区别在初始化的时候
    def __init__(self, name, doug, sauc):
        self.__name = name  # 名字
        self.__doug = doug  # 面团
        self.__sauc = sauc  # 酱
        self.__topings = []  # 配料

    # ! 固定方法 begin
    def addTops(self, tops):  # 添加配料
        self.__topings.append(tops)

    def prepare(self):
        print("准备中")
        print("添加面团")
        print("添加酱料")
        print("添加配料")
        for tops in self.__topings:
            print(tops, " ")

    def bake(self):
        print("在350度下烘焙25分钟")

    def cut(self):
        print("把Pizza切成片")

    def box(self):
        print("把Pizza打包进盒子里")

    def getName(self):
        return self.__name

    # ! 固定方法 end


# ! 纽约cheese风格的pizza类
class NYStyleCheesePizza(Pizza):
    def __init__(self):
        Pizza.__init__(self, "纽约cheese风格的pizza", "薄皮面饼", "番茄酱")
        self.addTops("碎芝士奶酪Grated Reggiano Cheese")


# ! 纽约clam风格的pizza类
class NYStyleClamPizza(Pizza):
    def __init__(self):
        Pizza.__init__(self, "纽约clam风格的pizza", "薄皮面饼", "番茄酱")
        self.addTops("碎蛤蜊Grated Clam")


# ! 基类工厂:Pizza商店
class PizzaStore(abc.ABC):
    # ! 主要逻辑
    def oderPizza(self, pizza_type: str):  # 点披萨 
        pizza = self.createPizza(pizza_type)
        pizza.prepare()
        pizza.bake()
        pizza.cut()
        pizza.box()
        return pizza

    # 生成具体的披萨 , 创建不同pizza
    @abc.abstractmethod
    def createPizza(self, pizza_type):
        pass


# ! 具体工厂:纽约pizza店
class NYPizzaStore(PizzaStore):

    # ! 实现抽象方法
    def createPizza(self, pizza_type):
        # * 通过具体类的方法创建具体商品
        if pizza_type in ["cheese", "芝士"]:
            return NYStyleCheesePizza()

        elif pizza_type in ["clam", "蛤蜊"]:
            return NYStyleClamPizza()

        else:
            return None


# ! ! ! 其他城市的pizza店...


def main():
    pizza_store = NYPizzaStore()
    pizza = pizza_store.oderPizza("clam")
    print(f"请拿好您的{pizza.getName()}")


if __name__ == "__main__":
    main()
